package com.csair.irp.job.file.task;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 调度解析日志表
 * </p>
 *
 * @author magicY
 * @since 2017-07-22
 */
@TableName("t_dispatch_log")
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
public class DispatchLogPO extends Model<DispatchLogPO> {

    private static final long serialVersionUID = 1L;

    /**
     * 调度日志任务状态
     */
    public enum StateEnum{
        ETL_STATE_INGORE(-1,"忽略操作"),
        ETL_STATE_NO_RUN(0,"未解析"),
        ETL_STATE_RUN_SUCCESS(1,"解析成功"),
        ETL_STATE_RUN_FAILURE(2,"解析失败"),
        ETL_STATE_RUNNING(3,"执行中"),
        ETL_STATE_FILE_NOT_FOUND(4,"未上传"),
        ETL_STATE_RESEND(5,"重推"),
        ETL_STATE_PARSER_NOT_FOUND(6,"未配置模板解析类")
        ;
        private int code;
        private String name;
        StateEnum(int code,String name){
            this.code = code;
            this.name = name;
        }

        public int getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }


    @TableField("id")
    private Long id;
    @TableField("dispatch_date")
    private Date dispatchDate;  //当天日期（解析日期）
    @TableField("data_resource_type_id")
    private Long dataResourceTypeId; //数据来源类型ID，与t_file_baseinfo的id关联
    @TableField("is_datafile")
    private Integer isDatafile;  //是否在FTP存放数据文件
    @TableField("etl_state")
    private Integer etlState;   //解析状态：0-未解析，1-解析成功，2-解析失败，3-执行中，4-未上传，5-重推
    @TableField("update_count")
    private BigDecimal updateCount; //影响的数据条数
    @TableField("dispatch_time")
    private Long dispatchTime; //解析所用的时间	单位秒
    @TableField("transaction_date")
    private Date transactionDate;
    @TableField("creation_time")//默认时间
    private Date creationTime;
    @TableField("error_log")//异常情况
    private String errorLog;
    @TableField("account_state")//网关对账状态
    private Integer accountState;
    @TableField("log_type")//任务调度日志类型
    private Integer logType;
    @TableField("resource_ids") //网关文件ID
    private String resourceIds;


    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
